using UnityEngine;
using UnityEngine.EventSystems;
using Framework;
using Framework.UI;


namespace Game
{
    public sealed class CharacterPanel : UIPanel, IDragHandler
    {
        CharacterScene m_FakeScene;

        private void Awake()
        {
            if (!GameRoot.HaveInstance()) return;
            this.LoadFakeScene().Coroutine();
        }

        private async FVoid LoadFakeScene()
        {
            GameObject prefab = await GameEntry.Resource.LoadPrefabAsync(AssetUtility.GetFakeScene("CharacterScene"));
            GameObject fakeScene = GameObject.Instantiate(prefab);
            fakeScene.transform.ResetRPS();
            this.m_FakeScene = fakeScene.GetComponent<CharacterScene>();
            await this.m_FakeScene.RefreshCharacter("YBot");
        }

        private void OnDestroy()
        {
            if (this.m_FakeScene)
            {
                GameObject.Destroy(this.m_FakeScene.gameObject);
                this.m_FakeScene = null;
            }    
        }

        public void OnClickLeftBtn()
        {
            
        }

        public void OnClickRightBtn()
        {

        }

        public void OnClickCloseBtn()
        {
            this.Close();
        }

        public void OnDrag(PointerEventData eventData)
        {
            this.m_FakeScene.RotateCamera(eventData.delta.x);
        }

    }
}